<?php

namespace app\models\db;

use Yii;

/**
 * This is the model class for table "t_main_page".
 *
 * @property string $mini_programs_id
 * @property integer $hot_goods_num
 * @property integer $newest_goods_num
 * @property integer $recommend_goods_num
 * @property integer $free_express_goods_num
 * @property integer $promotion_goods_num
 * @property integer $hot_goods_sort
 * @property integer $newest_goods_sort
 * @property integer $recommend_goods_sort
 * @property integer $free_express_goods_sort
 * @property integer $promotion_goods_sort
 * @property string $create_datetime
 * @property string $id
 *
 * @property MiniPrograms $miniPrograms
 */
class MainPage extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_main_page';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['hot_goods_num', 'newest_goods_num', 'recommend_goods_num', 'free_express_goods_num', 'promotion_goods_num', 'hot_goods_sort', 'newest_goods_sort', 'recommend_goods_sort', 'free_express_goods_sort', 'promotion_goods_sort'], 'integer'],
            [['create_datetime'], 'safe'],
            [['id'], 'required'],
            [['mini_programs_id', 'id'], 'string', 'max' => 36],
            [['mini_programs_id'], 'exist', 'skipOnError' => true, 'targetClass' => MiniPrograms::className(), 'targetAttribute' => ['mini_programs_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'mini_programs_id' => 'Mini Programs ID',
            'hot_goods_num' => 'Hot Goods Num',
            'newest_goods_num' => 'Newest Goods Num',
            'recommend_goods_num' => 'Recommend Goods Num',
            'free_express_goods_num' => 'Free Express Goods Num',
            'promotion_goods_num' => 'Promotion Goods Num',
            'hot_goods_sort' => 'Hot Goods Sort',
            'newest_goods_sort' => 'Newest Goods Sort',
            'recommend_goods_sort' => 'Recommend Goods Sort',
            'free_express_goods_sort' => 'Free Express Goods Sort',
            'promotion_goods_sort' => 'Promotion Goods Sort',
            'create_datetime' => 'Create Datetime',
            'id' => 'ID',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getMiniPrograms()
    {
        return $this->hasOne(MiniPrograms::className(), ['id' => 'mini_programs_id']);
    }
}
